-- 12

x = 1099511627000    -- starting point, pre-calculated
d = 1e-4
y = x + d
i = 0

while x ~= y do
	x = x + 1
	y = x + d

	i = i + 1
	print(i, string.format('%.11f', x), d, string.format('%.11f', y))
end

if x == y then
	print(i, x)
end

print('log2(x) == ' .. tostring(math.log(x) / math.log(2)))
print()

do
	local x, y, d = x, x + d, d
	local i = 0
	print(string.format('debug\tx=%.12f, y=%.12f, d=%.12f, i=%d', x, y, d, i))
	while x == y do
		y = x + d
		d = d + 1e-4

		i = i + 1
		print(string.format('debug.\tx=%.12f, y=%.12f, d=%.12f, i=%d', x, y, d, i))
	end

	print(i, string.format('%.12f', x), string.format('%.12f', y))
end
